<{extend name="base" /}>
    <{block name="body" }>
        <div class="layui-body ">
            <div class="layui-tab layui-tab-brief">
                <ul class="layui-tab-title">
                    <ul class="layui-tab-title">
                        <li class="">
                            <a href="<{:url('admin/sm/index')}>">已添加列表</a>
                        </li>
                        <li>
                            <a href="<{:url('admin/sm/create',['style_id'=>1])}>">样式一</a>
                        </li>
                        <li class="layui-this">
                            <a href="<{:url('admin/sm/create',['style_id'=>2])}>">样式二</a>
                        </li>
                        <li >
                            <a href="<{:url('admin/sm/create',['style_id'=>3])}>">样式三</a>
                        </li>
                        <li>
                            <a href="<{:url('admin/sm/create',['style_id'=>4])}>">样式四</a>
                        </li>
                    </ul>
                </ul>
                <div class="layui-tab-content">
                    <div class="layui-tab-item layui-show" id="app">
                        <div class="left">
                            <form class="layui-form" method="post" action="<{:url('admin/sm/save')}>">
                                <input type="hidden" name="style" value="2">
                                <{php}>
                                if(request()->action() == 'edit'){
                                    echo '<input type="hidden" name="type" value="edit">';
                                    echo '<input type="hidden" name="id" value="'.request()->get('id').'">';
                                }
                                <{/php}>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">标题</label>
                                    <div class="layui-input-block">
                                        <input type="text" name="content[title]"  lay-verify="required" v-model='title' placeholder="{用此符号可飘红，支持多个} 必须成对书写"
                                            class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">链接</label>
                                    <div class="layui-input-block">
                                        <input type="text" name="content[url]" v-model="url" lay-verify="required|url" placeholder="例如：http://baidu.com" class="layui-input">
                                    </div>
                                </div>

                                <div class="layui-form-item layui-form-text">
                                    <label class="layui-form-label">回答一</label>
                                    <div class="layui-input-block">
                                        <textarea name="content[desc1]" lay-verify="required" v-model='desc1'  placeholder="{用此符号可飘红，支持多个} 必须成对书写"
                                            class="layui-textarea" ></textarea>
                                    </div>
                                </div>

                                <div class="layui-form-item layui-form-text">
                                    <label class="layui-form-label">回答二</label>
                                    <div class="layui-input-block">
                                        <textarea name="content[desc2]" lay-verify="required" v-model='desc2'  placeholder="{用此符号可飘红，支持多个} 必须成对书写"
                                            class="layui-textarea" ></textarea>
                                    </div>
                                </div>


                                <div class="layui-form-item">
                                    <div class="layui-input-block">
                                        <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                                    </div>
                                </div>
                            </form>
                        </div>
                        <div class="right" id="sm-search">
                            <link rel="stylesheet" href="/sm/css/style.css" />
                                <div class="sc card sc_zhidao">
                                    <a :href="url" class="sc-title">
                                        <i v-html="Ctitle"></i>
                                        <img src="" alt="手机版" class="phone-type">
                                    </a>
                                    <div class="zd-content">
                                        <div class="zd-summary sc-padding">
                                            <p class="zd-question" v-html="Cdesc1"></p>
                                            <p class="zd-satisfy-answer" v-html="Cdesc2"></p>
                                        </div>
                                    </div>
                                </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <{/block}>
            <{block name="script" }>
                <style type="text/css">
                    .left,
                    .right {
                        float: left;
                    }

                    .left {
                        width: 60%;
                    }

                    .right {
                        height: 550px;
                        margin-left: 60px;
                        width: 300px;
                        border: 2px solid #ccc;
                        border-radius: 20px;
                        padding: 20px 13px;
                        background: #f1f1f1;
                        box-shadow: 1px 2px #eeeeee5c;
                        overflow-y: scroll;
                    }

                    .right::-webkit-scrollbar {
                        display: none;
                    }
                </style>
                <script src="/static/js/vue.js"></script>
                <script type="text/javascript">
                    var vue = new Vue({
                        el: "#app",
                        data: {
                            title: '',
                            desc1:'',
                            desc2:'',
                            url: '',
                        },
                        computed: {
                            Ctitle: function () {
                                if (this.title == '') {
                                    return '<em>人流</em>大概多少钱';
                                }
                                return this.title.replace(/{/g, '<em>').replace(/}/g, '</em>');
                            },
                            Cdesc1:function(){
                                if (this.desc1 =='') {
                                    return '性别：女 年龄：37岁 病情描述及疑问：我在上大学呢,因为和男友同居在一起,...';
                                }
                                return this.desc1.replace(/{/g, '<em>').replace(/}/g, '</em>');
                            },
                            Cdesc2:function(){
                                if (this.desc2 =='') {
                                    return '建议：妇科专家推荐技术—“德国WOLF宫腔镜无痛取胚术”该项技术综合了目前人流技术中最先...';
                                }
                                return this.desc2.replace(/{/g, '<em>').replace(/}/g, '</em>');
                            }
                        }
                    });

                    <{php}>
                        if(request()->action() == 'edit'){

                            echo "vue.title = '".$data['content']['title']."';";
                            echo "vue.url = '".$data['content']['url']."';";

                            echo "vue.desc1 = '".$data['content']['desc1']."';";
                            echo "vue.desc2 = '".$data['content']['desc2']."';";

                            
                        }
                    <{/php}>

                </script>
                <{/block}>